Skip to main content

Inspect-AI–based agents and tools.

Project description

inspect_agents

Inspect‑AI–native agents with typed state, safe tools, and rich traces.

This library extends Inspect‑AI with higher‑level agent orchestration, typed state (todos and virtual files), and a small set of Inspect‑native tools. It is safe by default: optional standard tools (think, web_search, bash/python, web_browser, text_editor) are gated behind environment flags, and sandboxed filesystem operations are constrained.

Quick Demo

Build Tests Lint Coverage License: MIT PyPI Version PyPI Downloads Last Commit Docs

Quickstart (self‑contained)

Uses local sources via PYTHONPATH and requires no provider setup. This validates the code path without contacting external services.

export PYTHONPATH=src:external/inspect_ai
python examples/inspect/quickstart_toy.py
# Expected: Completion: DONE

Next: Examples — Start Here →

Docs Home →

Why Inspect Agents?

Setting up practical LLM agents is slow: you fight glue code, logging, state, and tool orchestration. Inspect Agents removes overhead with an Inspect‑AI‑native workflow: typed state (todos/files), built‑in tools, and rich transcripts/traces by default. You can run a toy agent offline in seconds (see Quickstart above).

Key Features

  • ✅ Inspect-native tools: Todos + virtual filesystem
    • Default: in-memory “store” (ephemeral; isolated per run)
    • Optional: sandbox (routes through Inspect’s text_editor/bash_session; delete disabled)
    • Sandbox quickstart: see docs/how-to/filesystem_sandbox_quickstart.md
    • Advanced: set include_defaults=False on build_supervisor, build_iterative_agent, or YAML configs to opt out of auto-injected todos/files while keeping prompts aligned with your custom toolchain.
    • Curated presets: call inspect_agents.tools.minimal_fs_preset() (Todos + FS) or inspect_agents.tools.full_safe_preset() (Todos + FS + env-gated standard tools) to rebuild safe bundles when you disable defaults.
  • ✅ Optional standard tools (gated by env flags):
    • INSPECT_ENABLE_THINK (default on), INSPECT_ENABLE_WEB_SEARCH (auto when provider keys set), INSPECT_ENABLE_EXEC, INSPECT_ENABLE_WEB_BROWSER, INSPECT_ENABLE_TEXT_EDITOR_TOOL (default off)
    • The stateful bash_session tool is never exposed by this repo; it’s used internally for sandbox FS.
  • ✅ Typed state: Pydantic models backed by Inspect Store for Todos and Files
  • ✅ Sub‑agents: “handoff” (transfer to transfer_to_<name>) or “tool” (single‑shot)
  • ✅ Traces & transcripts: Structured tool events and store change logs by default
  • ✅ Safe by default: approval presets (dev/prod), quarantine filters, sandbox confinement/symlink denial
  • ✅ Self‑contained toy example to verify setup without external model providers

Table of Contents

  • Installation
  • Usage (CLI and Python)
  • Logs & Inspect View
  • Examples
  • Documentation
  • Project Status
  • Contributing
  • Support

Installation

  • Python 3.11+ on macOS or Linux.
  • For packaging/install instructions (pip or uv), see the docs site. The Quickstart above runs from source.

Configure Environment Variables

If you use Inspect CLI or providers, see the Environment reference and the example configurator:

For the self‑contained Quickstart above, no configuration is required.

Usage

Scaffold a new agent

Generate a minimal agent module in seconds.

# Creates src/<package>/<name>.py  (<package> is the dotted package path; <name> is normalized to snake_case)
python scripts/scaffold_agent.py my_helper --path . --package inspect_agents --no-test

Notes

  • Safe by default: refuses to overwrite existing files unless --force (or confirms y/N when interactive).
  • The template uses build_iterative_agent(code_only=True) so it runs without exec/search/browser tools.
  • Creates src/<package>/<name>.py (under src/<package>/; <name> is normalized to snake_case, e.g., "MyAgent" → my_agent.py).
  • By default a smoke test is also created at tests/<package>/test_<name>.py; in the example above we pass --no-test to skip it (omit --no-test to generate the test).

FS tools (store mode)

Short, deterministic example that writes, lists, and reads a file using the in‑memory store (no host filesystem writes).

import asyncio, os

# Ensure store mode (default), i.e., in‑memory virtual filesystem
os.environ["INSPECT_AGENTS_FS_MODE"] = "store"

from inspect_agents.tools import write_file, read_file, ls

async def main():
    w = write_file(); r = read_file(); l = ls()
    await w(file_path="demo.txt", content="Hello\nWorld")
    print(await l())                  # → ["demo.txt"]
    print(await r(file_path="demo.txt", offset=0, limit=10))
    # → numbered output:
    #     1\tHello
    #     2\tWorld

asyncio.run(main())

Note: In store mode these paths live in an in‑memory store tied to the current process context, not your disk. For sandbox mode, see the quickstart: docs/how-to/filesystem_sandbox_quickstart.md and the full guide: docs/how-to/filesystem.md.

CLI (Inspect)

When using Inspect CLI and tasks, see:

Policy note: Enabling INSPECT_ENABLE_EXEC=1 exposes only single‑shot bash() and python() tools. The stateful bash_session tool is never surfaced by this repo’s standard_tools(); it is reserved for internal filesystem‑sandbox operations (e.g., sed, ls, wc -c).

Viewing Logs (Inspect View)

Inspect provides a log viewer. See: docs/cli/inspect_view.md

Advanced Usage

Sub‑agents Configuration

Define sub‑agents in YAML and load programmatically. See: docs/guides/subagents.md

Architecture

flowchart LR
    SP[[System Prompt / Config]] --> S[Supervisor]
    MR[Model Resolver] --> S
    S --> L[Logs / Traces]
    S -->|tool call| AP[Approvals & Policies]
    AP --> ST[Stateless Tools]
    AP --> SS[Stateful Tools]
    ST -.-> S
    SS -.-> S

    subgraph "FS Path Modes (MODE=store|sandbox)"
      direction LR
      FST[FS Tools] -->|"store (default)"|VFS["(VFS)"]
      FST -->|sandbox| SBX[["Sandboxed Editor (no delete)"]]
      SBX --> HFS[(Host FS)]
    end
    AP --> FST
    VFS -.-> S
    SBX -.-> S
    HFS -.-> S

    S -->|handoff| CG[Context Gate]
    CG <-->|iterate| SA[Sub-Agents]
    SA -.-> S

Fallback: docs/diagrams/architecture_overview.png

Documentation

Docs (MkDocs)

To preview docs locally, see: docs/README.md

Project Status

  • Version: 0.0.1 (repo) / see PyPI badge for latest
  • Status: Beta
  • Python: 3.11+ (tested on 3.12)
  • Roadmap: Milestones | Projects

Coming Soon

  • CI workflows (tests, lint, coverage) and release automation
  • Expanded examples for web_browser and sandboxed exec
  • Additional sub-agent templates (researcher, coder, editor)

Contributing

See CONTRIBUTING.md for guidelines.

Quick Setup for Contributors

See CONTRIBUTING.md for up‑to‑date dev environment instructions.

Support

License & Acknowledgments

  • Licensed under MIT
  • Thanks to the Inspect-AI project and ecosystem
  • Inspired by CLI-first DX from projects like Bun and Supabase

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inspect_agents-0.0.2.tar.gz (254.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inspect_agents-0.0.2-py3-none-any.whl (107.7 kB view details)

Uploaded Python 3

File details

Details for the file inspect_agents-0.0.2.tar.gz.

File metadata

  • Download URL: inspect_agents-0.0.2.tar.gz
  • Upload date:
  • Size: 254.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for inspect_agents-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2a5f5a5c0229f2e78e059b71a32dfc9b105d56f4220843d808016ba6c47839bd
MD5 50d863a2e290ee054168d2ab68c340c4
BLAKE2b-256 1a88a0926788cc75dda4ecb80492be789d4c9e8ace45c9a40dbd3ed6832cd4d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for inspect_agents-0.0.2.tar.gz:

Publisher: release.yml on cnm13ryan/inspect_agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inspect_agents-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: inspect_agents-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 107.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for inspect_agents-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8792a5682811e9a9abeea473f7fdc8c4e6e1921df74424c442c5d6e4741674c6
MD5 000538cb2eb6d71726d6d6547a5caba7
BLAKE2b-256 7979f49cb07f68ffd51e6fc66e5ed8bf23a08eab90b522903bc7c806c8a67729

See more details on using hashes here.

Provenance

The following attestation bundles were made for inspect_agents-0.0.2-py3-none-any.whl:

Publisher: release.yml on cnm13ryan/inspect_agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page